package com.lcu.wl.common.utils;

import org.apache.http.HttpStatus;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 */
public class SYSDATA extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public SYSDATA() {
        put("code", 0);
        put("msg", "success");
    }

    public static SYSDATA error() {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常，请联系管理员");
    }

    public static SYSDATA error(String msg) {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
    }

    public static SYSDATA error(int code, String msg) {
        SYSDATA SYSDATA = new SYSDATA();
        SYSDATA.put("code", code);
        SYSDATA.put("msg", msg);
        return SYSDATA;
    }

    public static SYSDATA ok(String msg) {
        SYSDATA SYSDATA = new SYSDATA();
        SYSDATA.put("msg", msg);
        return SYSDATA;
    }

    public static SYSDATA ok(Map<String, Object> map) {
        SYSDATA SYSDATA = new SYSDATA();
        SYSDATA.putAll(map);
        return SYSDATA;
    }

    public static SYSDATA ok() {
        return new SYSDATA();
    }

    public SYSDATA put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}

